export const mockForm = (arr: string[]) => {
  const list: any[] = [];

  arr.forEach((item) => {
    const obj = {
      type: "input",
      label: item,
      prop: item,
      placeholder: item,
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    };
    list.push(obj);
  });

  return list;
};

export const mockFieldMap = (arr: string[]) => {
  const fieldMap: any = {};
  arr.forEach((item) => {
    fieldMap[item] = item;
  });
  fieldMap.operate = {
    label: "操作",
    slot: "operate",
    fixed: "right",
    width: "180px",
  };
  return fieldMap;
};

export const mockList = (arr: string[]) => {
  const list: any = [];
  let total = 0;

  const len = 10;

  const createVal = (item: string) => {
    const map: any = {
      日期: "2025-09-27",
      号: "20250926BJ0043",
      "状态	": "已完成",
      时间: "2026-09-26 23:59:59",
      金额: "5250",
      类型: "小型轿车",
      车牌号: "京A12345",
      性别: "男",
      数量: 100,
    };

    for (const key in map) {
      if (item.includes(key)) {
        return map[key];
      }
    }

    return item;
  };

  for (let i = 0; i < len; i++) {
    const obj: any = {};
    arr.forEach((item) => {
      obj[item] = createVal(item);
    });
    list.push(obj);
    total++;
  }

  return {
    list,
    total,
  };
};
